package com.tvunetworks.center.user.mapper;

import com.tvunetworks.center.user.model.RoleManagement;
import com.tvunetworks.center.user.model.param.PageRoleParam;
import com.tvunetworks.center.user.model.vo.PageRoleVo;
import com.tvunetworks.center.user.model.vo.RoleManagementVo;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author Etan Yang
 * @data: 2021/4/7 15:22
 * @program: tvucc-aggregator
 * @description:
 */

public interface RoleManagementMapper extends Mapper<RoleManagement> {

    /**
     * 根据parentUserId和roleName获取RoleManagement对象
     * @param roleName roleName
     * @param parentUserId parentUserId
     * @return RoleManagement
     */
    RoleManagement getRoleManagementByRoleNameAndUserId(@Param("roleName") String roleName, @Param("parentUserId") String parentUserId);


    /**
     * 分页查询指定用户下的role集合
     * @param userId userId
     * @param param param
     * @return List
     */
    List<RoleManagementVo> pageRole(@Param("userId") String userId, @Param("param") PageRoleParam param);

    /**
     * 分页查询该用户下的roleName
     * @param userId userId
     * @param param param
     * @return List
     */
    List<PageRoleVo> pageRoleName(@Param("userId") String userId, @Param("param") PageRoleParam param);

    /**
     * 根据parentUserId和roleId获取RoleManagement对象
     * @param roleId roleId
     * @param userId userId
     * @return RoleManagement
     */
    RoleManagement getRoleManagementByRoleIdAndUserId(@Param("roleId") String roleId, @Param("userId")String userId);

    /**
     * 根据userId获取所有的Role
     * @param userId userId
     * @return List
     */
    List<RoleManagement> getRoleManagementByUserId(@Param("userId")String userId);

    /**
     * 解除device在role_manage表中的绑定关系
     * @param userId userId
     * @param peerIds peerIds
     */
    void deleteByUserIdAndPeerId(@Param("userId")String userId,@Param("peerIds") List<String> peerIds);

    /**
     *
     * @return userid 集合
     */
    List<String> getUserId();

    /**
     * 根据peerid删除设备
     * @param peerId peerId
     */
    void deleteRoleDeviceByPeerId(@Param("peerId")String peerId);
}
